<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.41">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #0000bf}
span.s3 {color: #000000}
span.s4 {color: #606060}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>WaveLoss<span class="Apple-tab-span">	</span></b></span><b>Lose bits of your waves</b></p>
<p class="p2"><br></p>
<p class="p3"><span class="Apple-tab-span">	</span><b>WaveLoss.ar(in, drop, outof, mode, mul, add)</b></p>
<p class="p2"><br></p>
<p class="p3">Uses the zero-crossings to divide an audio stream into tiny segments, and simply discards a fraction of the segments (replacing them with silence). The technique was described in a lecture by Trevor Wishart.</p>
<p class="p2"><br></p>
<p class="p3">Parameters: the filter drops <b><i>drop</i></b> out of <b><i>outof</i></b> chunks. <b><i>mode</i></b> can be 1 to drop chunks in a simple deterministic fashion (e.g. always dropping the first 30 out of a set of 40 segments), or 2 to drop chunks randomly but in an appropriate proportion.</p>
<p class="p2"><br></p>
<p class="p3"><b>Example</b></p>
<p class="p4"><br></p>
<p class="p5">s.boot;</p>
<p class="p6">// Move the mouse left/right to see the gradation of the effect.<span class="Apple-converted-space"> </span></p>
<p class="p6">// Move up or down to choose mode. The modes sound very different.</p>
<p class="p5">(</p>
<p class="p5">x = {</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> sig, mode;</p>
<p class="p5"><span class="Apple-tab-span">	</span>sig = [<span class="s2">SinOsc</span>.ar, <span class="s2">PinkNoise</span>.ar].mean;</p>
<p class="p5"><span class="Apple-tab-span">	</span>mode = <span class="s2">MouseY</span>.kr(1,2).round;</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">WaveLoss</span>.ar(sig, <span class="s2">MouseX</span>.kr(0, 40), 40, mode: mode, mul: 0.1);</p>
<p class="p5">}.play;</p>
<p class="p5">)</p>
<p class="p5">x.free;</p>
<p class="p7"><br></p>
<p class="p6">// Plotting shows quite clearly what's going on:</p>
<p class="p5">(</p>
<p class="p5">{</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> sig;</p>
<p class="p5"><span class="Apple-tab-span">	</span>sig = [<span class="s2">SinOsc</span>.ar, <span class="s2">PinkNoise</span>.ar].mean;</p>
<p class="p5"><span class="Apple-tab-span">	</span>[sig, <span class="s2">WaveLoss</span>.ar(sig, 20, 40, mode: 2)];</p>
<p class="p5">}.plot(0.15);</p>
<p class="p5">)</p>
<p class="p7"><br></p>
<p class="p7"><br></p>
<p class="p6">// A stereo example, evolves over a couple of minutes - specify a breakbeat loop sample below, sounds good</p>
<p class="p6"><span class="s3">b = </span><span class="s2">Buffer</span><span class="s3">.read(s,</span><span class="s4">"sounds/amenfast.wav"</span><span class="s3">); </span>// remember to free the buffer later.</p>
<p class="p5">(</p>
<p class="p5">x = {</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> sig, mode, woo;</p>
<p class="p5"><span class="Apple-tab-span">	</span>sig = <span class="s2">PlayBuf</span>.ar(1, b.bufnum, <span class="s2">BufRateScale</span>.kr(b.bufnum) * 0.75, startPos: 92898, loop: 1);</p>
<p class="p5"><span class="Apple-tab-span">	</span>woo = {</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">WaveLoss</span>.ar(sig,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>.new([199, 199, 150, 150, 199, 250], [20, 40, 60, 60, 100]), doneAction:2)</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>+ (<span class="s2">FSinOsc</span>.kr(0.2 + <span class="s2">XLine</span>.kr(0.001, [1.3, 1.7], 90), 0, 50) * <span class="s2">XLine</span>.kr(0.00000001, 1, 60))</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>,</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>200, mode: 2, mul: 0.4);</p>
<p class="p5"><span class="Apple-tab-span">	</span>}.dup;</p>
<p class="p5"><span class="Apple-tab-span">	</span>woo = (woo * 0.9) + (woo.reverse * 0.1);</p>
<p class="p5">}.play;</p>
<p class="p5">)</p>
<p class="p5">x.free;</p>
<p class="p5">b.free;</p>
</body>
</html>
